/*
 * Copyright 2011 Clean GWT
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.cleangwt.bootstrap.client.ui;

import com.google.gwt.dom.client.Element;

/**
 * The bootstrap's grid system.
 * 
 * @author Jess
 * @version 1.0
 * @since 1.0
 */
public class GridSystem {

  public static final String ROW_STYLE = "row";
  public static final String COL_LG_PREFIX = "col-lg-";
  public static final String COL_MD_PREFIX = "col-md-";
  public static final String COL_SM_PREFIX = "col-sm-";
  public static final String COL_XS_PREFIX = "col-xs-";

  public static final String COL_LG_OFFSET_PREFIX = "col-lg-offset-";
  public static final String COL_MD_OFFSET_PREFIX = "col-md-offset-";
  public static final String COL_SM_OFFSET_PREFIX = "col-sm-offset-";
  public static final String COL_XS_OFFSET_PREFIX = "col-xs-offset-";

  public static final int DEFAULT_COL_COUNT = 12;

  /**
   * Sets the div.
   * 
   * @param md the div for midium screen, 0 to ignore
   */
  public static void setDiv(Element e, int md) {
    assert md > 0;
    e.addClassName(COL_MD_PREFIX + md);
  }

  /**
   * Sets the div.
   * 
   * @param lg the div for large screen, 0 to ignore
   * @param md the div for midium screen, 0 to ignore
   * @param sm the div for small screen, 0 to ignore
   * @param xs the div for extra small screen, 0 to ignore
   */
  public static void setDiv(Element e, int lg, int md, int sm, int xs) {
    if (lg > 0) {
      e.addClassName(COL_LG_PREFIX + lg);
    }
    if (md > 0) {
      e.addClassName(COL_MD_PREFIX + md);
    }
    if (sm > 0) {
      e.addClassName(COL_SM_PREFIX + sm);
    }
    if (xs > 0) {
      e.addClassName(COL_XS_PREFIX + xs);
    }
  }

  /**
   * Sets the offset.
   * 
   * @param lg the offset for large screen, 0 to ignore
   * @param md the offset for midium screen, 0 to ignore
   * @param sm the offset for small screen, 0 to ignore
   * @param xs the offset for extra small screen, 0 to ignore
   */
  public static void setOffset(Element e, int lg, int md, int sm, int xs) {
    if (lg > 0) {
      e.addClassName(COL_LG_OFFSET_PREFIX + lg);
    }
    if (md > 0) {
      e.addClassName(COL_MD_OFFSET_PREFIX + md);
    }
    if (sm > 0) {
      e.addClassName(COL_SM_OFFSET_PREFIX + sm);
    }
    if (xs > 0) {
      e.addClassName(COL_XS_OFFSET_PREFIX + xs);
    }
  }
}